import { Component, OnInit } from '@angular/core';
import {FormControl, FormGroupDirective, NgForm, Validators} from '@angular/forms';
import {ErrorStateMatcher} from '@angular/material/core';
import { Router } from '@angular/router';
import {HttpServiceService} from '../service/http-service.service';
import { from } from 'rxjs';
@Component({
  selector: 'app-login',
  templateUrl: './login.component.html',
  styleUrls: ['./login.component.scss']
})
export class LoginComponent implements OnInit {

  constructor(public router: Router, private http: HttpServiceService) { }
name: string;
age: string;
isSpinning = false;
  ngOnInit() {
  }
  login() {
    this.isSpinning = true;
    const param = {
      name: this.name,
      age: this.age
    };
    this.http.post('addUser', param).subscribe(data => {
console.log(data);



if (data != null) {
  this.isSpinning = false;
  console.log('login');
  this.router.navigate(['home']);
}

    });
  }
}
